#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005, MAXM = 1000005;
struct pq {
	priority_queue<int> p, q;
	void push(int x) {p.push(x);}
	void erase(int x) {q.push(x);}
	bool empty() {
		while (p.empty() == 0 && q.empty() == 0 && p.top() == q.top()) p.pop(), q.pop();
		return p.empty();
	}
	int top() {
		while (p.empty() == 0 && q.empty() == 0 && p.top() == q.top()) p.pop(), q.pop();
		return p.top();
	}
};
struct node {int mx, mn, ans;};
pq rl[MAXM], rr[MAXM], gl, gr;
node operator + (const node &x, const node &y) {
	return {max(x.mx, y.mx), min(x.mn, y.mn), min({x.ans, y.ans, y.mn - x.mx})};
}
namespace sgt {
	node val[MAXM << 2];
	void pushup(int rt) {val[rt] = val[rt << 1] + val[rt << 1 | 1];}
	void build(int rt, int l, int r) {
		val[rt] = {-0x3f3f3f3f, 0x3f3f3f3f, 0x3f3f3f3f};
		if (l == r) return; int mid = (l + r) >> 1; build(rt << 1, l, mid); build(rt << 1 | 1, mid + 1, r);
		pushup(rt);
	}
	void update(int rt, int l, int r, int x) {
		if (l == r) {
			val[rt].mx = rl[x].empty() ? -0x3f3f3f3f : rl[x].top();
			val[rt].mn = rr[x].empty() ? 0x3f3f3f3f : -rr[x].top();
			val[rt].ans = 0x3f3f3f3f;
			return;
		} int mid = (l + r) >> 1; x <= mid ? update(rt << 1, l, mid, x) : update(rt << 1 | 1, mid + 1, r, x); pushup(rt);
	}

}
int main() {
	freopen("stone.in", "r", stdin); freopen("stone.out", "w", stdout);
	int n; scanf("%d", &n);
	sgt::build(1, 1, 999999);
	while (n--) {
		int l, r; char str[3]; scanf("%s %d %d", str, &l, &r); r--;
		if (str[0] == 'A') gl.push(l), gr.push(-r), rl[r].push(l), rr[l].push(-r);
		else gl.erase(l), gr.erase(-r), rl[r].erase(l), rr[l].erase(-r);
		sgt::update(1, 1, 999999, l); sgt::update(1, 1, 999999, r);
		if (gl.top() <= -gr.top()) printf("%d\n", -rr[gl.top()].top() - rl[-gr.top()].top() + 1);
		else printf("%d\n", sgt::val[1].ans + 1);
	}
}
/*
run stone < stone1.in > stone1.out
run stone < stone2.in > stone2.out
run stone < stone3.in > stone3.out
run stone < stone4.in > stone4.out
run stone < stone5.in > stone5.out
diff stone1.out stone1.ans -Z
diff stone2.out stone2.ans -Z
diff stone3.out stone3.ans -Z
diff stone4.out stone4.ans -Z
diff stone5.out stone5.ans -Z
*/